<?php
mysql_select_db($database_konek, $konek);
$query_past = "SELECT * FROM artikelplug WHERE id = $pilih_sett";
$past = mysql_query($query_past, $konek) or die(mysql_error());
$row_past = mysql_fetch_assoc($past);
$totalRows_past = mysql_num_rows($past);
?>

<?php
mysql_select_db($database_konek, $konek);
$query_past2 = "SELECT * FROM artikelplug_data WHERE id_module = '$row_past[id]' ORDER BY id DESC LIMIT $row_past[perpage] ";
$past2 = mysql_query($query_past2, $konek) or die(mysql_error());
$row_past2 = mysql_fetch_assoc($past2);
$totalRows_past2 = mysql_num_rows($past2);
mysql_select_db($database_konek, $konek);
$query_sm = "SELECT * FROM artikelplug_data WHERE id_module = '$row_past[id]' ORDER BY id DESC ";
$sm = mysql_query($query_sm, $konek) or die(mysql_error());
$row_sm = mysql_fetch_assoc($sm);
$totalRows_sm = mysql_num_rows($sm);
if ($totalRows_past2>0){
?>
<div  class="<?php echo $classjudul ?>">
<?php echo $row_past['judul']; ?>
</div>
<div class="<?php echo $classcontent; ?>">
  <?php $num=0; do { ?>
  
  <div class="media">
  <a class="pull-left" href="<?php echo $base_url ?>/p/artikelplug/detail/<?php echo $pilih_sett ?>/<?php echo preg_replace("/[^a-zA-Z0-9]+/", "-", $row_past2['nama']); ?>/<?php echo $row_past2['id']; ?>">
    <img class="media-object" src="<?php echo $base_url ?>/g-konten/fm/artikel/<?php echo $row_past['id']; ?>/thumb/<?php echo $row_past2['image']; ?>" alt="<?php echo $num++ ?>">
  </a>
  <div class="media-body">
    <h4 class="media-heading"><?php echo $row_past2['nama']; ?></h4>
    <small><?php echo tgl_indo($row_past2['tanggal']); ?> | dilihat :  <?php echo $row_past2['view']; ?> kali </small><p>

    <?php echo substr($row_past2['isi'],0,150); ?> ...</p>
<a href="<?php echo $base_url ?>/p/artikelplug/detail/<?php echo $pilih_sett ?>/<?php echo preg_replace("/[^a-zA-Z0-9]+/", "-", $row_past2['nama']); ?>/<?php echo $row_past2['id']; ?>" class="btn btn-default" role="button">Read More</a>
  </div>
</div>
  
    <?php } while ($row_past2 = mysql_fetch_assoc($past2)); ?>
<?php if ($totalRows_sm>$row_past['perpage']) { ?>
<div style="width:100%; margin-top:20px">
<div class="btn-group">
  <a href="<?php echo $base_url ?>/p/artikelplug/category/<?php echo $row_past['id'] ?>/all/1">
  <button type="button" class="btn btn-default">Next</button>
  </a></div>
</div>
<?php } ?></div>
<?php
}
mysql_free_result($past2);
?>

<?php
mysql_free_result($past);
?>